#include <iostream>
#include <set>
#include <vector>
using std::cout;
using std::endl;
using std::set;
using std::pair;
using std::vector;

template <typename Container>
void display(const Container &con){
    for(auto & elem : con){
        cout << elem << " ";
    }
    cout << endl;
}

void test0(){
    set<int> number = {1,6,8,6,2,9,4,9,5,6,7,3,1};
    /* set<int,std::greater<int>> number = {1,8,6,6,2,9,4,9,5,6,7,3,1}; */
    display(number);

    cout << endl << "set查找"<< endl;
    size_t cnt = number.count(8);
    cout << "cnt=" << cnt << endl;

    auto it = number.find(4);
    if(it == number.end()){
        cout << "元素不在set中" << endl;
    }else{
        cout << "元素在set中" << endl;
    }
    
    cout << endl << "set插入"<< endl;
    
    pair<set<int>::iterator,bool> ret = number.insert(10);
    if(ret.second){
        cout << "插入成功" << endl;
    }else{
        cout << "插入失败" << endl;
    }
    display(number);

    pair<set<int>::iterator,bool> ret1 = number.insert(10);
    if(ret1.second){
        cout << "插入成功" << endl;
    }else{
        cout << "插入失败" << endl;
    }
    display(number);
    
    cout << endl;
    number.insert({3,8,8,9,11,88,22});
    display(number);

    cout << endl;
    vector<int> vec = {20,40,50,60,8,8,1};
    number.insert(vec.begin(),vec.end());
    display(number);
}

int main(int argc, char * argv[])
{
    test0();
    return 0;
}


